package durak.client.view;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.SystemColor;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import durak.common.model.CommonPlayerData;
import durak.common.model.GameTableState;

public class ScoreBoardView extends JFrame {
	
	public CommonPlayerData playerData;
	public GameTableState gameState;
	/**
	 * Launch the application.
	 */
	
	JPanel panel = new JPanel();
	JLabel label = new JLabel();
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ScoreBoardView frame = new ScoreBoardView();
					frame.setVisible(true);
					JPanel panel = new JPanel();
					JLabel label = new JLabel();
					
					label.setIcon(new ImageIcon("/durak/resources/images/SIX_SPADES.png"));
					panel.add(label);
					
					frame.getContentPane().add(panel);

					
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public ScoreBoardView() {
		getContentPane().setBackground(Color.GREEN);
		setTitle("Score Board");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		getContentPane().setLayout(null);
		
		JLabel lblScoreBoard = new JLabel("Score Board");
		lblScoreBoard.setForeground(SystemColor.activeCaption);
		lblScoreBoard.setBounds(164, 31, 101, 22);
		lblScoreBoard.setBackground(Color.WHITE);
		getContentPane().add(lblScoreBoard);
		
		int highestScore = 0;
		String bigLoser= "";
		for (CommonPlayerData player : gameState.getPlayers()) {
			if (player.getLoses() > highestScore) {
				highestScore = player.getLoses();
				bigLoser = player.getName();
			}
		}
		
		for ( CommonPlayerData player : gameState.getPlayers())
		{
		
		JLabel lblPlayername = new JLabel(player.getName());
		lblPlayername.setBackground(SystemColor.desktop);
		lblPlayername.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblPlayername.setLabelFor(this);
		lblPlayername.setForeground(SystemColor.info);
		lblPlayername.setBounds(29, 60, 43, 14);
		getContentPane().add(lblPlayername);
		
		JLabel lblNewLabel = new JLabel(Integer.toString(player.getLoses()));
		lblNewLabel.setBounds(87, 60, 52, 14);
		getContentPane().add(lblNewLabel);
	}
	}

}





